package com.qf.common;

/**
 * 基于ThreadLocal封装的工具类,保存和获取用户当前登录的id
 */
public class MyThreadLocal {

    //构件一个ThreadLocal
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     *设置值
     * @param id
     */
    public static void setCreateUser(Long id) {
       threadLocal.set(id);
    }

    /**
     * 获取值
     * 放行
     * @return
     */
    public static Long getCreateUser() {
       return threadLocal.get();
    }
}
